using System;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Collections.Generic;
using System.Reflection;

namespace Xdt.Fnb.Data
{
  /// <summary>
  /// LetterHeaderAndFooter Data Object Class
  /// </summary>
  public partial class DOLetterHeaderAndFooter
  {
    #region Class Constant declarations
    		/// <summary>
		/// The Table Column for the LetterHeaderAndFooter HeaderFont
		/// </summary>
		public const string RowHeaderFont = "HeaderFont";

		/// <summary>
		/// The Table Column for the LetterHeaderAndFooter HeaderFontSize
		/// </summary>
		public const string RowHeaderFontSize = "HeaderFontSize";

		/// <summary>
		/// The Table Column for the LetterHeaderAndFooter HeaderFontStyle
		/// </summary>
		public const string RowHeaderFontStyle = "HeaderFontStyle";

		/// <summary>
		/// The Table Column for the LetterHeaderAndFooter HeaderText
		/// </summary>
		public const string RowHeaderText = "HeaderText";

		/// <summary>
		/// The Table Column for the LetterHeaderAndFooter HeaderImagePath
		/// </summary>
		public const string RowHeaderImagePath = "HeaderImagePath";

		/// <summary>
		/// The Table Column for the LetterHeaderAndFooter FooterFont
		/// </summary>
		public const string RowFooterFont = "FooterFont";

		/// <summary>
		/// The Table Column for the LetterHeaderAndFooter FooterFontSize
		/// </summary>
		public const string RowFooterFontSize = "FooterFontSize";

		/// <summary>
		/// The Table Column for the LetterHeaderAndFooter FooterFontStyle
		/// </summary>
		public const string RowFooterFontStyle = "FooterFontStyle";

		/// <summary>
		/// The Table Column for the LetterHeaderAndFooter FooterText
		/// </summary>
		public const string RowFooterText = "FooterText";


#region Stored Procedures
private const string m_StoredProcedureConstCreate = "spLetterHeaderAndFooter_Create";
private const string m_StoredProcedureConstDelete = "spLetterHeaderAndFooter_Delete";
private const string m_StoredProcedureConstRetrieve = "spLetterHeaderAndFooter_Retrieve";
private const string m_StoredProcedureConstRetrieveall = "spLetterHeaderAndFooter_Retrieveall";
private const string m_StoredProcedureConstUpdate = "spLetterHeaderAndFooter_Update";
#endregion
    
    
    #endregion

    #region Class Variable declarations
    	#region DO Variables
		private string m_HeaderFont;
		private decimal m_HeaderFontSize;
		private string m_HeaderFontStyle;
		private string m_HeaderText;
		private string m_HeaderImagePath;
		private string m_FooterFont;
		private decimal m_FooterFontSize;
		private string m_FooterFontStyle;
		private string m_FooterText;
	#endregion
    
	#region Default Variables
	private SQLDataObject sqlData;
	private List<DOLetterHeaderAndFooter> m_LetterHeaderAndFooters = new List<DOLetterHeaderAndFooter>();
	#endregion
	
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Class Constructor
    /// </summary>
    public DOLetterHeaderAndFooter() { }
    #endregion

    #region Class Properties
    #region DO Properties
		/// <summary>
		/// HeaderFont
		/// </summary>
		/// <remarks>
		/// This property contains the LetterHeaderAndFooter HeaderFont
		/// </remarks>
		public string HeaderFont
		{
			get { return (this.m_HeaderFont); }
			set { this.m_HeaderFont = value; }
		}

		/// <summary>
		/// HeaderFontSize
		/// </summary>
		/// <remarks>
		/// This property contains the LetterHeaderAndFooter HeaderFontSize
		/// </remarks>
		public decimal HeaderFontSize
		{
			get { return (this.m_HeaderFontSize); }
			set { this.m_HeaderFontSize = value; }
		}

		/// <summary>
		/// HeaderFontStyle
		/// </summary>
		/// <remarks>
		/// This property contains the LetterHeaderAndFooter HeaderFontStyle
		/// </remarks>
		public string HeaderFontStyle
		{
			get { return (this.m_HeaderFontStyle); }
			set { this.m_HeaderFontStyle = value; }
		}

		/// <summary>
		/// HeaderText
		/// </summary>
		/// <remarks>
		/// This property contains the LetterHeaderAndFooter HeaderText
		/// </remarks>
		public string HeaderText
		{
			get { return (this.m_HeaderText); }
			set { this.m_HeaderText = value; }
		}

		/// <summary>
		/// HeaderImagePath
		/// </summary>
		/// <remarks>
		/// This property contains the LetterHeaderAndFooter HeaderImagePath
		/// </remarks>
		public string HeaderImagePath
		{
			get { return (this.m_HeaderImagePath); }
			set { this.m_HeaderImagePath = value; }
		}

		/// <summary>
		/// FooterFont
		/// </summary>
		/// <remarks>
		/// This property contains the LetterHeaderAndFooter FooterFont
		/// </remarks>
		public string FooterFont
		{
			get { return (this.m_FooterFont); }
			set { this.m_FooterFont = value; }
		}

		/// <summary>
		/// FooterFontSize
		/// </summary>
		/// <remarks>
		/// This property contains the LetterHeaderAndFooter FooterFontSize
		/// </remarks>
		public decimal FooterFontSize
		{
			get { return (this.m_FooterFontSize); }
			set { this.m_FooterFontSize = value; }
		}

		/// <summary>
		/// FooterFontStyle
		/// </summary>
		/// <remarks>
		/// This property contains the LetterHeaderAndFooter FooterFontStyle
		/// </remarks>
		public string FooterFontStyle
		{
			get { return (this.m_FooterFontStyle); }
			set { this.m_FooterFontStyle = value; }
		}

		/// <summary>
		/// FooterText
		/// </summary>
		/// <remarks>
		/// This property contains the LetterHeaderAndFooter FooterText
		/// </remarks>
		public string FooterText
		{
			get { return (this.m_FooterText); }
			set { this.m_FooterText = value; }
		}
		#endregion
    
	#region Default Properties
	public List<DOLetterHeaderAndFooter> LetterHeaderAndFooters
	{
	  get { return m_LetterHeaderAndFooters; }
	  set { m_LetterHeaderAndFooters = value; }
	}    
	#endregion
	
    #endregion

    #region Class Methods
    public bool Retrieve()
    {
      sqlData = new SQLDataObject();
      DataSet resultDS = sqlData.ExecuteDataSetSQL(m_StoredProcedureConstRetrieve + " @" + RowHeaderFont + "=" + this.HeaderFont);
      return SetClassPropertiesFromDataSet(resultDS);
    }

    public bool RetrieveAll()
    {
      sqlData = new SQLDataObject();
      string sVariables = sqlData.GetVariables(this);

      DataSet resultDS = sqlData.ExecuteDataSetSQL(m_StoredProcedureConstRetrieveall + " " + sVariables);
      return SetClassPropertiesListFromDataSet(resultDS);
    }

    public bool Create()
    {
      bool success = false;
      sqlData = new SQLDataObject();
      string sVariables = sqlData.GetVariables(this);

      success = sqlData.ExecuteNonQuerySQL(m_StoredProcedureConstCreate + " " + sVariables);

      return success;
    }

    public bool Update()
    {
      bool success = false;
      sqlData = new SQLDataObject();

      string sVariables = sqlData.GetVariables(this);

      success = sqlData.ExecuteNonQuerySQL(m_StoredProcedureConstUpdate + " " + sVariables);

      return success;
    }

    private bool SetClassPropertiesFromDataSet(DataSet resultDS)
    {
      bool success = false;
      if (resultDS.Tables[0] != null)
      {
        if (resultDS.Tables[0].Rows.Count > 0)
        {
          foreach (DataRow dr in resultDS.Tables[0].Rows)
          {
					if (dr[RowHeaderFont].ToString() != "")
			this.HeaderFont = dr[RowHeaderFont].ToString();

		if (dr[RowHeaderFontSize].ToString() != "")
			this.HeaderFontSize = decimal.Parse(dr[RowHeaderFontSize].ToString());

		if (dr[RowHeaderFontStyle].ToString() != "")
			this.HeaderFontStyle = dr[RowHeaderFontStyle].ToString();

		if (dr[RowHeaderText].ToString() != "")
			this.HeaderText = dr[RowHeaderText].ToString();

		if (dr[RowHeaderImagePath].ToString() != "")
			this.HeaderImagePath = dr[RowHeaderImagePath].ToString();

		if (dr[RowFooterFont].ToString() != "")
			this.FooterFont = dr[RowFooterFont].ToString();

		if (dr[RowFooterFontSize].ToString() != "")
			this.FooterFontSize = decimal.Parse(dr[RowFooterFontSize].ToString());

		if (dr[RowFooterFontStyle].ToString() != "")
			this.FooterFontStyle = dr[RowFooterFontStyle].ToString();

		if (dr[RowFooterText].ToString() != "")
			this.FooterText = dr[RowFooterText].ToString();
          }
          success = true;
        }
      }
      return success;
    }

    private bool SetClassPropertiesListFromDataSet(DataSet resultDS)
    {
      bool success = false;
      if (resultDS.Tables[0] != null)
      {
        if (resultDS.Tables[0].Rows.Count > 0)
        {
          foreach (DataRow dr in resultDS.Tables[0].Rows)
          {
            DOLetterHeaderAndFooter LetterHeaderAndFooter = new DOLetterHeaderAndFooter();
			
					if (dr[RowHeaderFont].ToString() != "")
			LetterHeaderAndFooter.HeaderFont = dr[RowHeaderFont].ToString();

		if (dr[RowHeaderFontSize].ToString() != "")
			LetterHeaderAndFooter.HeaderFontSize = decimal.Parse(dr[RowHeaderFontSize].ToString());

		if (dr[RowHeaderFontStyle].ToString() != "")
			LetterHeaderAndFooter.HeaderFontStyle = dr[RowHeaderFontStyle].ToString();

		if (dr[RowHeaderText].ToString() != "")
			LetterHeaderAndFooter.HeaderText = dr[RowHeaderText].ToString();

		if (dr[RowHeaderImagePath].ToString() != "")
			LetterHeaderAndFooter.HeaderImagePath = dr[RowHeaderImagePath].ToString();

		if (dr[RowFooterFont].ToString() != "")
			LetterHeaderAndFooter.FooterFont = dr[RowFooterFont].ToString();

		if (dr[RowFooterFontSize].ToString() != "")
			LetterHeaderAndFooter.FooterFontSize = decimal.Parse(dr[RowFooterFontSize].ToString());

		if (dr[RowFooterFontStyle].ToString() != "")
			LetterHeaderAndFooter.FooterFontStyle = dr[RowFooterFontStyle].ToString();

		if (dr[RowFooterText].ToString() != "")
			LetterHeaderAndFooter.FooterText = dr[RowFooterText].ToString();

            this.LetterHeaderAndFooters.Add(LetterHeaderAndFooter);
          }
          success = true;
        }
      }
      return success;
    }
    #endregion

    #region Class Support Methods
    #endregion
  }
}
